#include "General.h"

General::General()
{
    //ctor
}
int General::toInt(char* str) {
    int str_index = 0;
    int num = 0;
    for (; str[str_index] != '\0'; str_index++) {
        num = num * 10 + (str[str_index] - 48);
    }
    return num;
}
string General::toStr(int x) {
    string str = "";
    if (x == 0)
        str = "0";
    while (x) {
        str = char((x % 10) + 48) + str;
        x /= 10;
    }
    return str;
}

string General::format(int id) {
    string formatId;
    if (id < 10)
        formatId = "00" + toStr(id);
    else if (id < 100)
        formatId = "0" + toStr(id);
    else
        formatId = toStr(id);
    return formatId;
}
bool General::isNum(string num) {
    for (int itr = 0; itr < num.size(); itr++) {
        if (num[itr] < '0' || num[itr] > '9')
            return false;
    }
    return true;
}
General::~General()
{
    //dtor
}
